// const BASE_URL = 'https://tea.qingnian8.com/api/bizhi'
const BASE_URL = 'http://localhost:3000/api'

export function request(confing={}){
	let {
		url,
		data={},
		method="GET",
		header={}
		}=confing
	url = BASE_URL+url;
	header['access-key'] = "954329";
	return new Promise((resolve,reject)=>{
		uni.request({
		url,
		data,
		method,
		header,
		success:res=>{
			// console.log('p333res',res);
			 // const {res.data.errCode} = res
			 // debugger
			if(res.data.errCode === 0){
				resolve(res.data)
			}else if(res.data.errCode === 400){
				uni.showModal({
					title:"错误提示",
					content:res.data.errMsg,
					showCancel:false
				})
				reject(res.data)
			}else{
				uni.showToast({
					title:res.data.errMsg,
					icon:"none"
				})
				reject(res.data)
			}
			
		},
		fail:err=>{
			reject(err)
		}
	})
	})
	
}

